package com.ruoyi.xinke.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.xinke.domain.AlgsNewCourse;
import com.ruoyi.xinke.service.IAlgsNewCourseService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 新开课Controller
 * 
 * @author ruoyi
 * @date 2023-03-20
 */
@RestController
@RequestMapping("/course")
public class AlgsNewCourseController extends BaseController
{
    @Autowired
    private IAlgsNewCourseService algsNewCourseService;

    /**
     * 查询新开课列表
     */
//    @RequiresPermissions("course:course:list")
    @GetMapping("/list")
    public TableDataInfo list(AlgsNewCourse algsNewCourse)
    {
        startPage();
        List<AlgsNewCourse> list = algsNewCourseService.selectAlgsNewCourseList(algsNewCourse);
        return getDataTable(list);
    }

    /**
     * 导出新开课列表
     */
//    adad
//    @RequiresPermissions("course:course:export")
    @Log(title = "新开课", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgsNewCourse algsNewCourse)
    {
        List<AlgsNewCourse> list = algsNewCourseService.selectAlgsNewCourseList(algsNewCourse);
        ExcelUtil<AlgsNewCourse> util = new ExcelUtil<AlgsNewCourse>(AlgsNewCourse.class);
        util.exportExcel(response, list, "新开课数据");
    }

    /**
     * 获取新开课详细信息
     */
//    @RequiresPermissions("course:course:query")
    @GetMapping(value = "/{newCourseId}")
    public AjaxResult getInfo(@PathVariable("newCourseId") Long newCourseId)
    {
        return success(algsNewCourseService.selectAlgsNewCourseByNewCourseId(newCourseId));
    }

    /**
     * 新增新开课
     */
//    @RequiresPermissions("course:course:add")
    @Log(title = "新开课", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgsNewCourse algsNewCourse)
    {
        return toAjax(algsNewCourseService.insertAlgsNewCourse(algsNewCourse));
    }

    /**
     * 修改新开课
     */
//    @RequiresPermissions("course:course:edit")
    @Log(title = "新开课", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgsNewCourse algsNewCourse)
    {
        return toAjax(algsNewCourseService.updateAlgsNewCourse(algsNewCourse));
    }

    /**
     * 删除新开课
     */
//    @RequiresPermissions("course:course:remove")
    @Log(title = "新开课", businessType = BusinessType.DELETE)
	@DeleteMapping("/{newCourseIds}")
    public AjaxResult remove(@PathVariable Long[] newCourseIds)
    {
        return toAjax(algsNewCourseService.deleteAlgsNewCourseByNewCourseIds(newCourseIds));
    }
}
